import { Component } from "react";
import './list.scss'
class List extends Component {
    state = {}
    
    //  删除
    dle = (index)=>{
        this.props.list.splice(index,1) 
        console.log(this);    
        this.setState({
           list: this.props.list
        })
     }

    render() {
        return (<>
            <div className='content'>
                <ul>
                    {
                        this.props.list.map((item, index) =>
                            <li key={index}>
                                <h3>评论人:{item.title}</h3>
                                <p>评论内容:{item.content}</p>
                                <button onClick={() => this.dle(index)}>删除</button>
                            </li>
                        )
                    }

                </ul>
            </div>
        </>)
    }


}
export default List